﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace IBasicsDal.BaseConstraint
{
    /// <summary>
    /// 基本新增约束
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public partial interface IBaseDal<T>
    {

        /*
         * 新增单条数据
         * 返回受影响的行数
         */

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity">表实体</param>
        /// <returns>返回受影响的行数</returns>
        public int Insert(T entity);

        /// <summary>
        /// 新增(异步)
        /// </summary>
        /// <param name="entity">表实体</param>
        /// <returns>返回受影响的行数</returns>
        public Task<int> InsertAsync(T entity);


        /*
         * 新增多条数据
         * 返回受影响的行数
         */

        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="entities"></param>
        /// <returns>返回受影响的行数</returns>
        public int Insert(List<T> entities);

        /// <summary>
        /// 批量新增(异步)
        /// </summary>
        /// <param name="entities">表实体</param>
        /// <returns>返回受影响的行数</returns>
        public Task<int> InsertAsync(List<T> entities);

        /*
         * 新增单条数据
         * 返回写入的数据自增列
         */

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>返回自增列</returns>
        public int InsertReturnIdentity(T entity);

        /// <summary>
        /// 新增(异步)
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>返回自增列</returns>
        public Task<int> InsertReturnIdentityAsync(T entity);

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>返回新增的实体</returns>
        public T InsertReturnEntity(T entity);

        /// <summary>
        /// 新增 (异步)
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>返回新增的实体</returns>
        public Task<T> InsertReturnEntityAsync(T entity);

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>返回新增的实体并带出自增列值</returns>
        public bool InsertRerunIdentityIntoEntity(T entity);

        /// <summary>
        /// 新增 (异步)
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>返回新增的实体并带出自增列值</returns>
        public Task<bool> InsertRerunIdentityIntoEntityAsync(T entity);
    }
}
